package com.lxk.mall.pms.domain.bo.spu;

import com.lxk.mall.pms.domain.PmsProductSpu;
import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;

import java.util.List;

/**
 * 管理后台 - 商品 SPU 新增/更新 Request VO
 */
@Data
@AutoMapper(target = PmsProductSpu.class, reverseConvertGenerate = false)
public class ProductSpuSaveReqBO {

    /**
     * 自增id
     */

    private Long id;

    /**
     * 商品编码
     */
    private String spuCode;

    /**
     * 商户id
     */
    private Long merId;

    /**
     * 商品类型
     */
    private String productType;

    /**
     * 商品名称
     */
    @NotBlank(message = "商品名称不能为空", groups = {AddGroup.class, EditGroup.class})
    private String name;

    /**
     * 关键字
     */
    @NotBlank(message = "关键字不能为空", groups = {AddGroup.class, EditGroup.class})
    private String keyword;

    /**
     * 商品简介
     */
    @NotBlank(message = "商品简介不能为空", groups = {AddGroup.class, EditGroup.class})
    private String introduction;

    /**
     * 商品详情
     */
    @NotBlank(message = "商品详情不能为空", groups = {AddGroup.class, EditGroup.class})
    private String description;

    /**
     * 商品分类编号
     */
    @NotNull(message = "商品分类不能为空", groups = {AddGroup.class, EditGroup.class})
    private Long categoryId;

    /**
     * 商品品牌编号
     */
    @NotNull(message = "商品品牌不能为空", groups = {AddGroup.class, EditGroup.class})
    private Long brandId;

    /**
     * 商品封面图
     */
    @NotBlank(message = "商品封面图不能为空", groups = {AddGroup.class, EditGroup.class})
    private String picUrl;

    /**
     * 商品轮播图
     */
    @NotEmpty(message = "商品轮播图地址数组", groups = {AddGroup.class, EditGroup.class})
//    @AutoMapping(target = "sliderPicUrls", expression = "java(java.lang.String.join(\",\", source.getSliderPicUrls()))")
    private String sliderPicUrls;

    /**
     * 排序字段
     */
    @NotNull(message = "商品排序字段不能为空", groups = {AddGroup.class, EditGroup.class})
    private Integer sort;

    // ========== SKU 相关字段 =========

    /**
     * 规格类型 0 单规格 1 多规格
     */
    @NotNull(message = "商品规格类型：不能为空", groups = {AddGroup.class, EditGroup.class})
    private Integer specType;

    /**
     * SKU
     */
    @Valid
    private List<ProductSkuSaveReqBO> skus;

    // ========== 物流相关字段 =========

    /**
     * 配送方式数组
     */
    @NotEmpty(message = "配送方式不能为空")
    private List<Integer> deliveryTypes;

    /**
     * 物流配置模板编号
     */
    private Long deliveryTemplateId;

    // ========== 营销相关字段 =========

    /**
     * 赠送积分
     */
    @NotNull(message = "商品赠送积分不能为空")
    private Integer giveIntegral;

    /**
     * 分销类型
     */
    @NotNull(message = "商品分销类型不能为空")
    private Integer subCommissionType;

    // ========== 统计相关字段 =========

    /**
     * 虚拟销量
     */
    private Integer virtualSalesCount;

    /**
     * 商品销量
     */
    private Integer salesCount;

    /**
     * 浏览量
     */
    private Integer browseCount;

    /**
     * spu状态
     */
    private Integer status;


}
